package top.wilbert.collegelink.user.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import top.wilbert.collegelink.user.entity.DynamicEntity;
import top.wilbert.collegelink.user.service.DynamicService;
import top.wilbert.collegelink.common.utils.PageUtils;
import top.wilbert.collegelink.common.utils.R;



/**
 * 
 *
 * @author Augus
 * @email 2531496343@qq.com
 * @date 2023-03-10 21:50:15
 */
@RestController
@RequestMapping("user/dynamic")
public class DynamicController {
    @Autowired
    private DynamicService dynamicService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("user:dynamic:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dynamicService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{dynamicId}")
//    @RequiresPermissions("user:dynamic:info")
    public R info(@PathVariable("dynamicId") Long dynamicId){
		DynamicEntity dynamic = dynamicService.getById(dynamicId);

        return R.ok().put("dynamic", dynamic);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("user:dynamic:save")
    public R save(@RequestBody DynamicEntity dynamic){
		dynamicService.save(dynamic);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("user:dynamic:update")
    public R update(@RequestBody DynamicEntity dynamic){
		dynamicService.updateById(dynamic);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("user:dynamic:delete")
    public R delete(@RequestBody Long[] dynamicIds){
		dynamicService.removeByIds(Arrays.asList(dynamicIds));

        return R.ok();
    }

}
